package bg.btanev.eightyfour.shared.dto.profile;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import bg.btanev.eightyfour.shared.dto.TagDto;
import bg.btanev.eightyfour.shared.dto.TargetDto;
import bg.btanev.eightyfour.shared.dto.dtobase.DomainDtoEntity;
import bg.btanev.eightyfour.shared.state.ProfileType;
import bg.btanev.eightyfour.shared.state.ProfileUpdateStatus;

/**
 *
 * @author B.Tanev
 *
 */
public abstract class ProfileDto<PE extends ProfileEventDto> extends DomainDtoEntity<Long> {
	/**
	 *
	 */
	private static final long serialVersionUID = -1454365831084340408L;

	private String name;
	private SortedSet<PE> profileEvents = new TreeSet<PE>();
	private Set<TagDto> tags = new HashSet<TagDto>();

	private Date lastUpdate;
	private ProfileUpdateStatus upateStatus;
	private ProfileType type;

	private TargetDto target;

	public ProfileDto() {
		super();
	}

	public ProfileType getType() {
		return type;
	}

	public void setType(ProfileType type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public SortedSet<PE> getProfileEvents() {
		return profileEvents;
	}

	public void setProfileEvents(SortedSet<PE> profileEvents) {
		this.profileEvents = profileEvents;
	}

	public Set<TagDto> getTags() {
		return tags;
	}

	public void setTags(Set<TagDto> tags) {
		this.tags = tags;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public ProfileUpdateStatus getUpateStatus() {
		return upateStatus;
	}

	public void setUpateStatus(ProfileUpdateStatus upateStatus) {
		this.upateStatus = upateStatus;
	}

	public TargetDto getTarget() {
		return target;
	}

	public void setTarget(TargetDto target) {
		this.target = target;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((lastUpdate == null) ? 0 : lastUpdate.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + ((upateStatus == null) ? 0 : upateStatus.hashCode());
		return result;
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProfileDto other = (ProfileDto) obj;
		if (lastUpdate == null) {
			if (other.lastUpdate != null)
				return false;
		} else if (!lastUpdate.equals(other.lastUpdate))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		if (upateStatus == null) {
			if (other.upateStatus != null)
				return false;
		} else if (!upateStatus.equals(other.upateStatus))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "ProfileDto [lastUpdate=" + lastUpdate + ", name=" + name + ", tags=" + tags + ", upateStatus="
				+ upateStatus + ", toString()=" + super.toString() + "]";
	}
}
